package com.miyang.controller;

import com.miyang.dao.UserDao;
import com.miyang.entity.UserEntity;
import com.miyang.service.UserServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by shijin.huang on 2019/2/19
 */
@Slf4j
@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserDao userDao;


    @Autowired
    private UserServiceImpl userService;

    @RequestMapping("/getUser")
    @ResponseBody
    public UserEntity getUser(Long id) {
        log.info("哈哈哈哈哈哈哈哈哈哈或");
        return userDao.getUser(id);
    }

    @GetMapping("/users")
    @ResponseBody
    public List<UserEntity> users() {
        return userService.getUsers();
    }

/*    @GetMapping("/insert")
    @ResponseBody
    public void insert() {
        try {
            userService.inserUsers();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }*/

}
